﻿/**
 * Author:
 *				Đỗ Việt Hoà
 * Copyright (c) 2012 Đỗ Việt Hoà <vit@launchar.com>.
 * 
 * This file is part of Launchar.
 * 
 * Launchar is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Launchar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Launchar.  If not, see <http://www.gnu.org/licenses/>.
 */

using System.Xml;

namespace vIT.Web.Configuration
{
	/// <summary>
	/// Configuration of membership.
	/// </summary>
	public class MembershipConfig
	{
		#region Attributes

		/// <summary>
		/// Gets the string value that is the name of the default provider.
		/// </summary>
		public string DefaultProvider { get; private set; }

		/// <summary>
		/// Gets the <see cref="vIT.Web.Configuration.ProviderConfigCollection"/> object that contains the collection of providers configuration.
		/// </summary>
		public ProviderConfigCollection Providers { get; private set; }

		#endregion

		#region Constructor

		/// <summary>
		/// Initializes a new instance of <see cref="vIT.Web.Configuration.MembershipConfig"/> class.
		/// </summary>
		public MembershipConfig(XmlNode xml)
		{
			if (xml == null)
			{
				this.DefaultProvider = string.Empty;
				this.Providers = new ProviderConfigCollection(null);
				return;
			}

			this.DefaultProvider = ((xml.Attributes["defaultProvider"] != null) ? xml.Attributes["defaultProvider"].Value : string.Empty);
			this.Providers = new ProviderConfigCollection(xml["providers"]);
		}

		#endregion
	}
}
